import Page
from Page import Personal
from Base.Base import Base
from selenium.webdriver.common.by import By


class PersonalLetterPage(Base):
    """
    个人中心来信界面
    """

    def __init__(self, driver):
        Base.__init__(self, driver)

        # 左侧的home键
        self.letter_home_btn = (By.XPATH, Personal.RESOURCE_ID.format("ivHome"))

        # 左侧的返回键
        self.letter_back_btn = (By.XPATH, Personal.RESOURCE_ID.format('ivBack'))

        # 头像图标
        self.letter_no_content_icon = (By.XPATH, Personal.no_connect_icon.format(""))

        # 头像标题
        self.letter_no_content_title_text = (By.XPATH, Personal.no_connect_text.format(""))

    def click_home(self):
        """
        点击左侧的home键

        :return:None
        """
        self.click_element(self.letter_home_btn)

    def click_back(self):
        """
        点击左侧的back键

        :return:None
        """
        self.click_element(self.letter_home_btn)

    def get_no_content(self, index=1):
        """
        获取来信图标

        :return:
        """
        self.letter_no_content_icon = (By.XPATH, Personal.no_connect_icon.format(index))
        return self.find_element_o(self.letter_no_content_icon)

    def get_no_content_title(self, index=1):
        """
        获取来信标题

        :return:
        """
        self.letter_no_content_title_text = (By.XPATH, Personal.no_connect_text.format(index))
        return self.find_element_o(self.letter_no_content_icon)

    def is_display_personal_avatar(self):
        """
        是否存在头像页

        :return: bool
        """
        return self.is_display(self.letter_no_content_icon)
